
from datetime import datetime

from spider.user_spider import user_blog_list
from dateutil.relativedelta import relativedelta
from domain.Blog import Blog



def get_user_blog_statistic(user_id):
    # 拿到博客列表信息
    # 当前时间
    now = datetime.now()
    one_month_ago = now - relativedelta(months=1)
    # 只保留日期部分
    start_date = one_month_ago.date()
    blog_list = user_blog_list(user_id, start_date)
    blog_class_list = []
    for obj in blog_list:
        blog_class = Blog(**obj, user_id=user_id)
        blog_class_list.append(blog_class)
    assert False
    return blog_class_list